<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>

		
	<body>
		<form action="http://www.test8899.com/reg.php" method="post">
			<table border="1" cellspacing="0" cellpadding="10px" id="tableId">
				<tr>
					<th></th>
					<th>姓名</th>
					<th>年龄</th>
					<th>性别</th>
					<th>家庭地址</th>
				</tr>
				<tr>
					<td><input type="checkbox" name="stu" id="" value="1" /></td>
					<td>遛马1</td>
					<td>18</td>
					<td>女</td>
					<td>非洲</td>
				</tr>
				<tr>
					<td><input type="checkbox" name="stu" id="" value="2" /></td>
					<td>遛马2</td>
					<td>18</td>
					<td>男</td>
					<td>非洲</td>
				</tr>
				<tr>
					<td><input type="checkbox" name="stu" id="" value="3" /></td>
					<td>遛马3</td>
					<td>18</td>
					<td>男</td>
					<td>非洲</td>
				</tr>
				<tr>
					<td><input type="checkbox" name="stu" id="" value="4" /></td>
					<td>遛马4</td>
					<td>18</td>
					<td>男</td>
					<td>非洲</td>
				</tr>
				<tr>
					<td><input type="checkbox" name="stu" id="" value="5" /></td>
					<td>遛马5</td>
					<td>18</td>
					<td>男</td>
					<td>非洲</td>
				</tr>			
			</table>
			<td><input type="checkbox" name="" id="checkAllID" value="" onclick="checkAll();"/></td>全选
			<td><input type="checkbox" name="" id="checkAllID1" value="" onclick="checkAllsex();"/></td>全选男
			<td><input type="checkbox" name="" id="checkAllID2" value="" onclick="checkAllma();"/></td>全选女
		</form>
	</body>
	<script type="text/javascript">
		function checkAll(){
			var tableobj=document.getElementById('tableId');
			var allSelinput=tableobj.getElementsByTagName('input');
			var checkAllIDvalue=document.getElementById('checkAllID');
			for(var i=0;i<allSelinput.length;i++){
				allSelinput[i].checked=checkAllIDvalue.checked;
			}
			}
			function checkAllsex(){
				var tableobj=document.getElementById('tableId');
				var allSelinput=tableobj.getElementsByTagName('input');
				var checkAllID1value=document.getElementById('checkAllID1');
				for(var i=0;i<allSelinput.length;i++){	
					allSelinput[i].checked=checkAllID1value.checked;
					if(allSelinput[i].checked==false){
						checkAllID1.checked=false;
						return;
					}
					}
					checkAllID1.checked=true;
			}
			
		function checkAllma(){
			var tableobj=document.getElementById('tableId');
				var allSelinput=tableobj.getElementsByTagName('input');
				var checkAllID2value=document.getElementById('checkAllID2');
				for(var i=0;i<allSelinput.length;i++){	
					allSelinput[i].checked=checkAllID2value.checked;
					if(allSelinput[i].checked==true){
						checkAllID2.checked=ture;
						return;
					}
					}
					checkAllID2.checked=false;
			}
		
	</script>
	
</html>
